<?php

class Users {
	public static function get($usr, $pw) {
		$ret = false;
		$file = fopen("users/pw.dat", "r") or Sys::error("Unable to open file!");
		while(!feof($file))
		  {
			$u = explode(":", fgets($file));
			if(strcmp(trim($u[1]),$usr)==0 && strcmp(trim($u[2]),$pw)==0){
				$ret = $u[0];
			}
		  }
		fclose($file);
		return $ret;
	}

	public static function lst(){
		$ret = array();
		$file = fopen("users/pw.dat", "r") or Sys::eror("Unable to open file!");
		//Output a line of the file until the end is reached
		while(!feof($file))
		  {
			$u = explode(":", fgets($file));
			$ret[$u[0]] = $u[1];
		  }
		fclose($file);
		return $ret;
	}
}

?>